<template>
  <z-modal
    :title="title"
    :width="600"
    v-bind="modalOption"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model layout="horizontal" labelAlign="right" ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol" :model="form" :rules="validatorRules">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="前置处理器" >
              <a-input placeholder="请输入前置处理器" :disabled="disableSubmit" v-model.trim="form.preProcess"/>
            </a-form-model-item>
          </a-col>
           <a-col :span="24" >
            <a-form-model-item label="权限范围">
              <a-select v-model="form.dataScope" allowClear :disabled="disableSubmit">
                <a-select-option :value="DATA_SCOPE.USER">按用户</a-select-option>
                <a-select-option :value="DATA_SCOPE.DEPT">按部门</a-select-option>
                <a-select-option :value="DATA_SCOPE.DEPT_AND_CHILD">部门及子部门</a-select-option>
                <a-select-option :value="DATA_SCOPE.SERVICE">按服务</a-select-option>
              </a-select>
            </a-form-model-item>
          </a-col>
          <a-col :span="24" v-if="form.dataScope === DATA_SCOPE.SERVICE">
            <a-form-model-item label="服务" prop="service">
              <a-input :disabled="disableSubmit" v-model="form.service"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24" >
            <a-form-model-item  label="描述">
              <a-input :disabled="disableSubmit" type="textarea" v-model="form.description"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </z-modal>
</template>

<script>
import ModalFormMixin from '@/mixins/ModalFormMixin'
// import { getAction } from '@/services/manage'
import { DATA_SCOPE } from '@/store/mutation-types'
export default {
  name: 'DataFilterModal',
  mixins: [ModalFormMixin],
  props: {
    dataResourceId: String
  },
  data() {
    return {
      DATA_SCOPE,
      validatorRules: {
        dataScope: [{ required: true, message: '请选择权限范围' }],
        service: [{ required: true, message: '请输入服务' }]
      },
      url: {
        add: '/datafilter/add',
        edit: '/datafilter/edit'
      }
    }
  },
  methods: {
    addAfter(row) {
      this.form.dataResourceId = this.dataResourceId
    },
    classifyIntoFormData() {
      return {
        ...this.form
      }
    }
  }
}
</script>

